package com.unisyou.leetcode;

public class NumMatrix {
    private int[][] matrixs;
    public NumMatrix(int[][] matrix) {
        this.matrixs = matrix;
    }

    public int sumRegion(int row1, int col1, int row2, int col2) {
        int sum = 0;
        int num = matrixs.length;
        for(int i=row1;i<=row2;i++){
            for(int j=col1;j<=col2;j++){
                sum += matrixs[i][j];
            }
        }
        return sum;
    }

    public static void main(String[] args) {
        int[][] matrix = {{3,0,1,4,2},{5,6,3,2,1},{1,2,0,1,5},{4,1,0,1,7},{1,0,3,0,5}};
        NumMatrix obj = new NumMatrix(matrix);
        int row1 = 1;
        int col1 = 4;
        int row2 = 3;
        int col2 = 4;
        int param_1 = obj.sumRegion(row1,col1,row2,col2);
        System.out.println(param_1);
    }
}
